<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Ananagrams</title>
<meta name="description" content="Ananagrams">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00156_files/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Ananagrams</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p>
Most crossword puzzle fans are used to <em>anagrams</em>--groups
of words with the same letters in different orders--for example
OPTS, SPOT, STOP, POTS and POST. Some words however do not have this
attribute, no matter how you rearrange their letters, you cannot form
another word. Such words are called <em>ananagrams</em>, an example is
QUIZ.
</p><p>
</p><p>
Obviously such definitions depend on the domain within which we are
working; you might think that ATHENE is an ananagram, whereas any
chemist would quickly produce ETHANE. One possible domain would be the
entire English language, but this could lead to some problems. One
could restrict the domain to, say, Music, in which case SCALE becomes
a <em>relative ananagram</em> (LACES is not in the same domain) but NOTE
is not since it can produce TONE.
</p><p>
</p><p>
Write a program that will read in the dictionary of a restricted
domain and determine the relative ananagrams. Note that single letter
words are, ipso facto, relative ananagrams since they cannot be
``rearranged'' at all. The dictionary will contain no more
than 1000 words.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input</a></font></h2>
<p>
Input will consist of a series of lines. No line will be more than 80
characters long, but may contain any number of words. Words consist of
up to 20 upper and/or lower case letters, and will not be broken
across lines. Spaces may appear freely around words, and at least one
space separates multiple words on the same line. Note that words that
contain the same letters but of differing case are considered to be
anagrams of each other, thus tIeD and EdiT are anagrams. The file will
be terminated by a line consisting of a single <tt>#</tt>.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Output</a></font></h2>
<p>
Output will consist of a series of lines. Each line will consist of a
single word that is a relative ananagram in the input dictionary.
Words must be output in lexicographic (case-sensitive) order. There
will always be at least one relative ananagram.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample input</a></font></h2>
<p>
</p><pre>ladder came tape soon leader acme RIDE lone Dreis peat
 ScAlE orb  eye  Rides dealer  NotE derail LaCeS  drIed
noel dire Disk mace Rob dries
#</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">Sample output</a></font></h2>
<p>
</p><pre>Disk
NotE
derail
drIed
eye
ladder
soon</pre>
<p>
</p></body></html>